set -x

cp_graph_lang(){
    echo "graph source dir为 $1:"
    graph_dir=$1
    graph_basename=`basename $graph_dir`
    rm -rf $graph_basename
    cp -r ${graph_dir}/graph $graph_basename

    # suffix=`echo $graph_basename | awk -F '_' '{print $2}'`
    mkdir $graph_basename/lang_new
    cp -r ${graph_dir}/lang_test/{phones,phones.txt} $graph_basename/lang_new

    rm -rf hotword_resource/{phones,phones.txt}
    ln -s ../$graph_basename/lang_new/phones hotword_resource/
    ln -s ../$graph_basename/lang_new/phones.txt hotword_resource/
    
}

# am_dir=/data/nfs5/nfs/aisearch/asr/cdxie/kaldi_20200821/egs/babel/train_tdnnf/exp/chain/tdnn1024_lstm1024.r512_train_5100h_input_1wh_all_rev_noise_aug_shuffle

# mkdir -p hotword_resource

# cp ${am_dir}/final.mdl ./
# cp ${am_dir}/tree hotword_resource/



# graph_dir=/data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/LM_hotwords/buildgraph/graph/graph_ssc_model_grammar

# # grmmar拷贝
# cp -r ${graph_dir}/{graph_grammar1,graph_grammar2a,graph_grammar2b} ./

# for i in 1 2a 2b
# do  
#     cp -r ${graph_dir}/lang_grammar${i} graph_grammar${i}/lang_new;
# done 

# rm -rf hotword_resource/{phones,phones.txt}
# ln -s ../graph_grammar1/lang_new/phones hotword_resource/
# ln -s ../graph_grammar1/lang_new/phones.txt hotword_resource/


if [ $# -eq 0 ]; then
    echo "you can usage:$0 <dir1-need-to-copy> <dir2-need-to-copy> ..."
    # exit
fi

for i in "$@"; do
    cp_graph_lang $i
done

# graph_dir=/data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/LM_hotwords/buildgraph/graph/graph_domain
# cp_graph_lang $graph_dir

# cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/LM_hotwords/buildgraph/graph/graph_domain_unk

# cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/LM_hotwords/buildgraph/graph/graph_domain_mix_jiaju0_07

# cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/LM_hotwords/buildgraph/graph/graph_jiaju_mix_with_domain0_07

# cp_graph_lang ~/workspace/project/LM_hotwords/buildgraph/graph/graph_iot_model_0620_no_vr_v1_4_without_unk

# cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/home_speech_music/buildgraph/graph/graph_home_speech_model_with_music_lambda0_5_exp1_0_03

#  cp_graph_lang ~/workspace/project/home_speech_music/buildgraph/graph/graph_home_speech_model_with_music_lambda0_5_exp1_0_07

#cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/home_speech_music/buildgraph/graph/graph_home_speech_model_with_music_lambda0_5_exp1_0_2

#cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/home_speech_music/buildgraph/graph/graph_home_speech_model_with_music_lambda0_5_exp1_0_5

#cp_graph_lang /data/nfs8/nfs/aisearch/asr/meichaoyang001/gpu_ke_aisearch_home/workspace/project/home_speech_music/buildgraph/graph/graph_home_speech_model_with_music_lambda0_5_exp1_0_8

#cp_graph_lang /data/cfs/asr_work/meichaoyang001/aisearch_gpu_home_new/workspace/LM_WORK/zimuyouhua/buildgraph/graph/graph_zimu_model_v2_0629_with_dabanhui_after_all_arpa_lambd0_2